﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace WeiboPlus.Shell.Views
{
    public partial class AboutPanorama : PhoneApplicationPage
    {
        public AboutPanorama()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (PhoneApplicationController.Current.AppSetting.EnableOrientationChange)
            {
                SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
            }
            else
            {
                var orientation = (SupportedPageOrientation)PhoneApplicationController.Current.AppSetting.CurrentSupportedOrientation;
                this.SupportedOrientations = orientation;
                this.Orientation = (PageOrientation)PhoneApplicationController.Current.AppSetting.CurrentOrientation;
            }
        }

        protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            base.OnOrientationChanged(e);
            if (PhoneApplicationController.Current.AppSetting.EnableOrientationChange)
            {
                switch (e.Orientation)
                {
                    case PageOrientation.LandscapeLeft:
                        LayoutRoot.SetValue(FrameworkElement.MarginProperty, new Thickness(0, 0, 70, 0));
                        break;
                    case PageOrientation.LandscapeRight:
                        LayoutRoot.SetValue(FrameworkElement.MarginProperty, new Thickness(70, 0, 0, 0));
                        break;
                    case PageOrientation.PortraitDown:
                        LayoutRoot.SetValue(FrameworkElement.MarginProperty, new Thickness(0, 0, 0, 70));
                        break;
                    case PageOrientation.PortraitUp:
                        LayoutRoot.SetValue(FrameworkElement.MarginProperty, new Thickness(0, 0, 0, 70));
                        break;
                    default:
                        break;
                }
            }
        }
    }
}